package com.sumainfor.common.config;

import lombok.extern.log4j.Log4j2;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;

/**
 * @Author Jack Chen
 * @Create 2019-01-25 17:02
 * 数据权限是否开启
 */
@SpringBootConfiguration
@ConditionalOnProperty(name = "auth.enable", havingValue = "true")
@Log4j2
public class AuthConfiguration {



    /**
     * 数据权限-查询
     *
     * @return
     */
    @Bean
    public SelectSqlInjector createSqlInjector() {
        log.info("数据权限-查询 开启成功! ");
        log.info("\n     _              _     _         _____                   _       _        \n" +
                "    / \\     _   _  | |_  | |__     | ____|  _ __     __ _  | |__   | |   ___ \n" +
                "   / _ \\   | | | | | __| | '_ \\    |  _|   | '_ \\   / _` | | '_ \\  | |  / _ \\\n" +
                "  / ___ \\  | |_| | | |_  | | | |   | |___  | | | | | (_| | | |_) | | | |  __/\n" +
                " /_/   \\_\\  \\__,_|  \\__| |_| |_|   |_____| |_| |_|  \\__,_| |_.__/  |_|  \\___|\n" +
                "                                                                             ");
        return new SelectSqlInjector();
    }


    /**
     * 数据权限-数据插入
     *`
     * @return
     */
    @Bean
    public InsertSqlInjector createInsertSqlInjector() {
        log.info("数据权限-数据插入 开启成功! ");
        return new InsertSqlInjector();
    }

}
